<template>
  <li class="list-group-item">
    <div class="handle">
      <a href="javascript:;" @click.prevent="deleteItem">删除</a>
    </div>
    <p class="user"><span>{{comment.username}}</span><span>说:</span></p>
    <p class="centence">{{comment.content}}</p>
  </li>
</template>

<script>
  export default {
    name: "Item",
    // 声明接收属性：这个属性就会成为组件对象的属性
    // 这种写法，指定属性名和属性值的类型
    props: {
      index: Number,
      comment: Object,
      deleteComment: {
        type: Function,
        required: true
      }
    },
    methods: {
      deleteItem() {
        const {comment, deleteComment, index} = this;
        // 提示框
        if (window.confirm(`确定删除${comment.username}的评论吗`)) {
          // 删除
          // this.key
          deleteComment(index);
        }

      }
    }
  }
</script>

<style scoped>
  li {
    transition: .5s;
    overflow: hidden;
  }

</style>
